package org.laobai.shop.admin.controller;

import java.util.List;

import org.apache.dubbo.config.annotation.DubboReference;
import org.laobai.shop.goods.entity.Spec;
import org.laobai.shop.goods.entity.SpecOption;
import org.laobai.shop.goods.service.SpecService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;

@Controller
@RequestMapping("spec")
public class SpecController {
	
	@DubboReference
	private SpecService specService;
	
	@RequestMapping("list")
	public String spec(int currPage, Spec spec,Model model){
		PageInfo<Spec> page = specService.page(currPage, spec);
		model.addAttribute("page",page);
		return "/spec/list";
	}
	
	@ResponseBody
	@RequestMapping("saveSpec")
	public boolean saveSpec(Spec spec){
		return specService.saveSpec(spec);
	}
	@ResponseBody
	@RequestMapping("getOptionsBySpecId")
	public List<SpecOption> getOptionsBySpecId(Integer specId){
		return specService.getOptionsBySpecId(specId);
	}
	
}
